/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.flota;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "tipo")
@NamedQueries({@NamedQuery(name = "Tipo.findAll", query = "SELECT t FROM Tipo t"), @NamedQuery(name = "Tipo.findByTipoCod", query = "SELECT t FROM Tipo t WHERE t.tipoCod = :tipoCod"), @NamedQuery(name = "Tipo.findByTipoDescripcion", query = "SELECT t FROM Tipo t WHERE t.tipoDescripcion = :tipoDescripcion")})
public class Tipo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="tipo_generator")
    @SequenceGenerator(name="tipo_generator", sequenceName="tipo_tipo_cod_seq", allocationSize=1)
    @Basic(optional = false)
    @Column(name = "tipo_cod")
    private Integer tipoCod;
    @Basic(optional = false)
    @Column(name = "tipo_descripcion")
    private String tipoDescripcion;
    @JoinTable(name = "tipo_caracteristica", joinColumns = {@JoinColumn(name = "tica_cod_tipo", referencedColumnName = "tipo_cod")},
    inverseJoinColumns = {@JoinColumn(name = "tica_cod_caracteristica", referencedColumnName = "cara_cod")})
    @ManyToMany
    private Collection<Caracteristica> caracteristicaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "plmaCodTipoVehiculo")
    private Collection<PlantillaMantenimiento> plantillaMantenimientoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vehiCodTipo")
    private Collection<Vehiculo> vehiculoCollection;

    public Tipo() {
    }

    public Tipo(Integer tipoCod) {
        this.tipoCod = tipoCod;
    }

    public Tipo(Integer tipoCod, String tipoDescripcion) {
        this.tipoCod = tipoCod;
        this.tipoDescripcion = tipoDescripcion;
    }

    public Integer getTipoCod() {
        return tipoCod;
    }

    public void setTipoCod(Integer tipoCod) {
        this.tipoCod = tipoCod;
    }

    public String getTipoDescripcion() {
        return tipoDescripcion;
    }

    public void setTipoDescripcion(String tipoDescripcion) {
        this.tipoDescripcion = tipoDescripcion;
    }

    public Collection<Caracteristica> getCaracteristicaCollection() {
        return caracteristicaCollection;
    }

    public void setCaracteristicaCollection(Collection<Caracteristica> caracteristicaCollection) {
        this.caracteristicaCollection = caracteristicaCollection;
    }

    public Collection<PlantillaMantenimiento> getPlantillaMantenimientoCollection() {
        return plantillaMantenimientoCollection;
    }

    public void setPlantillaMantenimientoCollection(Collection<PlantillaMantenimiento> plantillaMantenimientoCollection) {
        this.plantillaMantenimientoCollection = plantillaMantenimientoCollection;
    }

    public Collection<Vehiculo> getVehiculoCollection() {
        return vehiculoCollection;
    }

    public void setVehiculoCollection(Collection<Vehiculo> vehiculoCollection) {
        this.vehiculoCollection = vehiculoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tipoCod != null ? tipoCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tipo)) {
            return false;
        }
        Tipo other = (Tipo) object;
        if ((this.tipoCod == null && other.tipoCod != null) || (this.tipoCod != null && !this.tipoCod.equals(other.tipoCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.Tipo[tipoCod=" + tipoCod + "]";
    }

}
